package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.ItemPoJo;
import com.xbongbong.paas.field.SubFormPoJo;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * DEMO 枚举
 *
 * @author GuoJun.HU
 * @since V1.0
 * @date 2019/2/19 10:42
 */
@Getter
public enum DemoEnum {
    //模拟枚举
    NAME("text_1","name","名称",FieldTypeEnum.TEXT.getType(),4,1,0,0),
    STATUS("text_2","status","状态",FieldTypeEnum.COMBO.getType(),4,1,0,0),
    NUMBER("num_1","number","数字",FieldTypeEnum.NUM.getType(),4,1,0,0),
    SURCHARGE("subForm_1","surcharge","其他费用",FieldTypeEnum.SUB_FORM.getType(),4,1,0,0)
    ;
    private String attr;
    private String saasAttr;
    private String alias;
    private Integer filedType;
    /**
     *1、没有额外的
     *  2、查重
     * 3、启用+必填
     *4、启用+必填+查重
     */
    private Integer setType;
    /**1允许编辑数据,0禁止编辑数据*/
    private Integer editable;
    /**设置页(所有页面隐藏)1隐藏,0显示*/
    private Integer editHide;
    /** 0全部展示 1仅新建 2仅编辑 3仅列表 4新建编辑 6全部不展示....*/
    private Integer showType;

    DemoEnum(String attr, String saasAttr, String alias, Integer filedType, Integer setType, Integer editable, Integer editHide, Integer showType) {
        this.attr = attr;
        this.saasAttr = saasAttr;
        this.alias = alias;
        this.filedType = filedType;
        this.setType = setType;
        this.editable = editable;
        this.editHide = editHide;
        this.showType = showType;
    }

    public static List<DemoEnum> getAllEnum() {
        List<DemoEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public void initName(){

    }

    public void initStatus(FieldAttrEntity fieldAttrEntity){
        List<ItemPoJo> itemPoJoList = new ArrayList<>();
        ItemPoJo itemPoJo1 = new ItemPoJo();
        itemPoJo1.setText("状态1");
        itemPoJo1.setValue("状态1");
        itemPoJo1.setChecked(false);
        itemPoJo1.setFieldMap(new ArrayList<>());
        ItemPoJo itemPoJo2 = new ItemPoJo();
        itemPoJo2.setText("状态2");
        itemPoJo2.setValue("状态2");
        itemPoJo2.setChecked(false);
        itemPoJo2.setFieldMap(Arrays.asList(NUMBER.attr));
        itemPoJoList.add(itemPoJo1);
        itemPoJoList.add(itemPoJo2);
        fieldAttrEntity.setItems(itemPoJoList);
    }

    public void initNumber(){

    }

    public void initSurcharge(FieldAttrEntity fieldAttrEntity){
        SubFormPoJo subFormPoJo = new SubFormPoJo();
        List<FieldAttrEntity> items = new ArrayList<>();
        FieldAttrEntity item = InitExplainsHelper.setField("text_1","费用","fee",FieldTypeEnum.TEXT.getType(),4,1,0,1);
        items.add(item);
        subFormPoJo.setItems(items);
        fieldAttrEntity.setSubForm(subFormPoJo);
    }
}
